import request from '../utils/request'

export function getCourseType () {
  return request({
    method: 'get',
    url: 'app/course/type'
  })
}

export function getCourse (name, type, pageSize, currentPage) {
  return request({
    method: 'get',
    url: 'app/course/list',
    params: {
      name: name,
      type: type,
      'page-size': pageSize,
      'current-page': currentPage
    }
  })
}

export function putCourse (data) {
  return request({
    method: 'put',
    url: 'app/course',
    data: data
  })
}

export function putCourseItem (data) {
  return request({
    method: 'put',
    url: 'app/course/item',
    data: data
  })
}

export function postCourseItem (data) {
  return request({
    method: 'post',
    url: 'app/course/item',
    data: data
  })
}

export function postCourse (data) {
  return request({
    method: 'post',
    url: 'app/course',
    data: data
  })
}

export function getCourseItem (id) {
  return request({
    method: 'get',
    url: 'app/course/item',
    params: {
      id: id
    }
  })
}

export function deleteCourseItem (id, courseId) {
  return request({
    method: 'delete',
    url: 'app/course/item',
    params: {
      id: id,
      'course-id': courseId
    }
  })
}

export function deleteCourse (id) {
  return request({
    method: 'delete',
    url: 'app/course',
    data: {
      id
    }
  })
}
